package b4_searchtree;
/**
 * 测试二叉搜索树
 */
public class TestBST {
    public static void main(String[] args) {
        //构造二叉树
        int[] data = {28,16,30,13,22,29,42};
        BST bst = new BST();
        for(int i : data){
            bst.add(i);
        }

        //查找元素
        System.out.println(bst.contains(20)); //false
        //返回最小值
        System.out.println(bst.findMin()); //13
        //返回最大值
        System.out.println(bst.findMax()); //42
        //删除最大值
        bst.removeMax();
        //删除最小值
        bst.removeMin();
        //打印BST树
        System.out.println(bst);

        bst.remove(30);
        System.out.println(bst);
    }
}
